package com.starlink.common.enums;

import java.util.Arrays;

/**
 * @Auther: zhouyuhang01
 * @Date: 2024/4/15 16:33
 * @Description: FreeEnum
 * @Version 1.0.0
 */
public enum FreeEnum {
    PINKAGE(1, "包邮"),
    NOT_PINKAGE(0, "不包邮"),
    PIECE(0, "按件"),
    KG(1, "按重量"),
    ML(2, "按体积"),
    RADIUS(null, "ALL"),
    FA_HUO_SHIPING(0,"发货运输"),
    HUAN_HUO_SHIPING(1,"换货运输");

    private Integer type;
    private String desc;

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    FreeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static FreeEnum getByType(Integer type) {
        if (type == null) {
            return null;
        }
        return Arrays.stream(values()).filter(item -> type.equals(item.getType())).findFirst().orElse(null);
    }
}
